package com.ep.modules.app.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ep.common.utils.PageUtils;
import com.ep.modules.app.dao.AppSalespersonMapper;
import com.ep.modules.app.entity.AppSalesperson;
import com.ep.modules.app.entity.AppSalespersonExample;
import com.ep.modules.app.service.AppSalespersonService;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AppSalespersonServiceImpl implements AppSalespersonService {
    @Autowired
    private AppSalespersonMapper appSalespersonMapper;

    public PageUtils queryPage(Map<String, Object> params) {
        String searchKey = (String)params.get("searchKey");
        Long searchUserId = (Long)params.get("searchUserId");
        AppSalespersonExample example = new AppSalespersonExample();
        AppSalespersonExample.Criteria criteria = example.createCriteria();
        List<AppSalesperson> list = appSalespersonMapper.selectByExample(example);
        Page<AppSalesperson> page = new Page<>();
        page.setRecords(list);
        return new PageUtils(page);
    }

    public AppSalesperson getById(Long id) {
        return appSalespersonMapper.selectByPrimaryKey(id.intValue());
    }

    public void save(AppSalesperson entity) {
        appSalespersonMapper.insert(entity);
    }

    public void update(AppSalesperson entity) {
        appSalespersonMapper.updateByPrimaryKeySelective(entity);
    }

    public void deleteBatch(Long[] ids) {
        for (Long id : ids) {
                appSalespersonMapper.deleteByPrimaryKey(id.intValue());
        }
    }
}